import Koa, { Context } from 'koa'
/**
 * 全局异常捕获中间件
 */
const globalException = async (ctx: Context, next: Koa.Next) => {
  try {
    await next()
  } catch (err: any) {
    ctx.body = ctx.fail(`服务器错误：${err.toString()}`)
  }
}
export default globalException
